﻿@using Backend.JYD.Model;
@using Backend.JYD.Model.Task;
@using Backend.JYD.Business;
@using Backend.JYD.Common;
@using Backend.JYD.BLL;
@{
    ViewBag.Title = "退回任务";
    Layout = "~/Views/Shared/_LayoutWin.cshtml";
}
@using (Ajax.BeginForm("last", new AjaxOptions() { OnSuccess = "afterpost" }))
{
    <div class="ui_pop_body" style="width: 600px; height: 350px;">
        <div>
            <ul class="edit-ul">
            @{
                var lastModeles = this.ViewBag.LastModeles as List<TaskStepModel>;
                if (lastModeles != null && lastModeles.Count > 0)
                {
                    var manager = new RoleManager();
                    foreach (var info in lastModeles)
                    { 
                <li class="li01">
                    <span class="s01"><font color="red">*</font>选择返回步骤：</span>
                    <span class="s02">
                        <input type="radio" name="rdoStepId" id="@("rdoStepId" + info.StepId)" value="@info.StepId" title="@info.StepName"/>
                        <label for="@("rdoStepId" + info.StepId)">@info.StepName</label><br />
                    </span>                    
                </li>
                    }
                }
            }
                <li class="li01" style="height:90px;">
                    <span class="s01"><font color="red">*</font>备注：</span>
                    <span class="s02">
                        <textarea name="remark" id="remark" rows="5" style="width:300px;"></textarea>
                    </span>
                </li>
                <li class="li01">
                    <span class="s01"></span>
                    <span class="s02">
                        <input type="submit" value="提交" onclick="return check()"/>
                        @*@Ajax.ActionLink("提交", "Process", new AjaxOptions { HttpMethod = "POST", OnSuccess = "afterpost" })*@
                        <input type="button" value="取消" onclick="closeWin()"/>
                    </span>
                </li>
            </ul>
        </div>
        <input type="hidden" value="@this.ViewBag.TaskId" name="hidTaskId"/>
    </div>
    <script src="@Url.Content("~/skin/js/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        function afterpost(data) {
            if (data.code) {
                closeWinAndReload();
            }
            else {
                alert(data.msg);
            }
        }

        function check() {
            if ($('input[name="rdoStepId"]').length > 0) {
                if (!$('input[name="rdoStepId"]:checked').val()) {
                    alert("选择执行步骤");
                    return false;
                }
            }

            if (!$('#remark').val()) {
                alert("请填写原因。");
                $('#remark').focus();
                return false;
            }
            return true;
        }

    </script>
}
